Compiler

RSS for tag

Discuss the various compiler and toolchain technologies used in development.

Posts under Compiler tag

67 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

Circular Reference Error in Xcode 26
I have my project running perfectly fine on Xcode 16. However, in Xcode 26 it doesn't build due to an error that I do not understand. I have three files that pertain to this error: // FriendListResponse.swift import Foundation struct FriendListResponse: Decodable { var friendships: [Friendship] var collections: [FriendCollection] } // Friendship.swift import Foundation struct Friendship: Decodable { var createdAt: String var friendId: Int var friendUserId: Int // user ID of the friend var friendUsername: String var id: Int var tagNames: [String] } // FriendCollection.swift struct FriendCollection: Decodable { var id: Int var permalink: String var tagNames: [String] var title: String } On the first file, FriendListResponse.swift, I am the simple error message "circular reference." I do not understand how these self-contained structs could create a circular reference. Although I have other data types in my project, none of them are even referenced in these files except for Friendship and FriendCollection. The FriendListResponse is a struct that is created from JSON values that are fetched from an API. This is the function that fetches the JSON: public static func listFriends(username: String) async throws -> [Friendship] { let data = try await sendGETRequest( url: "people/\(username)/friends/list.json" ) print(String(data: data, encoding: .utf8)!) let decoder = JSONDecoder() decoder.keyDecodingStrategy = .convertFromSnakeCase let wrapper = try decoder.decode(FriendListResponse.self, from: data) return wrapper.friendships } // Note: the function sendGETRequest is just // a function that I have created that takes a set // of parameters and returns a data object // using the HTTP GET protocol. I don't think // that it is related to this issue. However, if you // think that it is, I can share the code for that. This error has also happened in a few other cases within contained networks of my data structure. I do not know why this error is only appearing once I launch Xcode 26 beta with my project files. I would think that this error also would appear in Xcode 16.4. Any help would be greatly appreciated in my process to compile my project on Xcode 26!
7
0
134
20h
Auto-Link Behavior Problem
Hi, I encountered an issue in my code where I directly used #import <CoreHaptics/CoreHaptics.h> without adding it to the "Link Binary With Libraries" section under Build Phases. My deployment target is iOS 12, and the code was running fine before; however, after upgrading Xcode, the app crashes immediately on an iOS 12 device with the following error message: DYLD, Library not loaded: /System/Library/Frameworks/CoreHaptics.framework/CoreHaptics | xx | Reason: image not found. Did Xcode modify the default auto-linking configuration? When did this behavior change in which version of Xcode? Do I need to specify CoreHaptics.framework as Optional in "Link Binary With Libraries"? Thanks for reply soon!
1
0
29
1w
❗️Xcode-beta: “missing required module ‘SwiftShims’” and C99 PCH conflict
Hi all, I’m running into a persistent build issue with my Swift project ORSOFINAL after migrating from Xcode stable to Xcode-beta.app 26 (June 2025 version). ⸻ 💥 Errors displayed: 1. C99 was enabled in PCH file but is currently disabled 2. module file .../ModuleCache.noindex/SwiftShims-AXUM98L131W4...pcm cannot be loaded due to a configuration mismatch with the current compilation 3. missing required module 'SwiftShims' ⸻ 🛠 What I’ve already tried: • xcode-select -s /Applications/Xcode-beta.app/Contents/Developer • Deleted ~/Library/Developer/Xcode/DerivedData, ModuleCache.noindex, Archives, and Products • Ran sudo xcodebuild -runFirstLaunch • Clean Build Folder in Xcode-beta • Verified Command Line Tools setting points to Xcode-beta ⸻ ❓Looking for guidance on: • Whether this is a known bug in Xcode-beta • If SwiftShims/PCM conflicts are expected between versions • Best practices to safely migrate from Xcode stable to beta for Swift-based projects Any advice is much appreciated. Thanks, Mathéo
1
0
42
2w
Xcode-beta project ORSOFINAL: SwiftShims & C99 PCH errors after migration from Xcode stable
Hi all, I’m running into a persistent build issue with my Swift project ORSOFINAL after migrating from Xcode stable to Xcode-beta.app (June 2025 version). ⸻ 💥 Errors displayed: 1. C99 was enabled in PCH file but is currently disabled 2. module file .../ModuleCache.noindex/SwiftShims-AXUM98L131W4...pcm cannot be loaded due to a configuration mismatch with the current compilation 3. missing required module 'SwiftShims' ⸻ 🛠 What I’ve already tried: • xcode-select -s /Applications/Xcode-beta.app/Contents/Developer • Deleted ~/Library/Developer/Xcode/DerivedData, ModuleCache.noindex, Archives, and Products • Ran sudo xcodebuild -runFirstLaunch • Clean Build Folder in Xcode-beta • Verified Command Line Tools setting points to Xcode-beta ⸻ ❓Looking for guidance on: • Whether this is a known bug in Xcode-beta • If SwiftShims/PCM conflicts are expected between versions • Best practices to safely migrate from Xcode stable to beta for Swift-based projects Any advice is much appreciated. Thanks, Mathéo
1
0
46
2w
Extract App Intents Metadata build error and SwiftConstValues files not being generated
Hello, We are reaching out to the official forum as an option to help us solve an issue we’re encountering with our app. The problem lies in the implementation of the AppIntents framework in our codebase, which, at the moment, is impossible to complete due to compilation errors occurring in specific targets of our app. We are currently using Xcode 16.0. First of all, we want to clarify that the integration of the AppIntents library poses no issues in our development targets (pre-production environments), since no additional code obfuscation steps are performed there. However, in the release targets used for production builds (those intended to be released to users), we encounter the following compilation error: These errors indicate that the “.swiftconstvalues” files are missing for all of the files in our application. We also want to highlight that we are using a code obfuscation tool called Arxan, provided by Digital.ai. This tool is integrated via specific Build Settings configurations, various files added to the project, and an additional Build Phase script. We have conducted the following tests: Disabling Arxan in release targets: The app compiles successfully and those files are generated (suspicious, I know). Adding a library with AppIntents references and an AppIntent in our app: Both scenarios produce the same compilation error. Creating a demo project with AppIntents and Arxan (basic implementation): The project compiles correctly and those files are in place. Contacting Digital.ai support: They suggested several changes to the Build Settings, but none of them resolved the issue. Additionally, we’ve attempted to gather information from the compiler to understand how these “.swiftconstvalues” files are generated. Unfortunately, we haven’t found any official documentation, so we would like to ask a few questions: Is it possible to interfere with the creation of these files in any way? For example, via scripts or other custom build steps? Is there any way to force the generation of these files through a build parameter or flag? Is it possible to bypass the “Extract App Intents Metadata” step during compilation? If so, what would be the implications of doing this when using a library that includes references to AppIntents? I know that involving a code obfuscation tool raises suspicions about it being the problem, we just want to know a little more about this compilation step to have some more context before reaching them again. Feel free to ask any questions or details, any reply is appreciated. Thanks
2
0
77
3w
Error in bnns.h - Missing ')'
Greetings! I have an app that builds ad runs just fine in XCode 11 on Catalina on an old Intel MBP. I've recently purchased an M3 Max machine and want to bring this app forward. Just going from XCode 11 to XCode 12 on the old machine, not even trying yet to up to XCode 14 or 15 on the new machine, I get two build errors that I have no idea how to resolve, both in bnns.h. I have not deliberately included this framework, and text search in my project and dependencies finds no incidence of "bnns" at all. These occur in the function prototypes for BNNSApplyMultiheadAttention and BNNSApplyMultiheadAttentionBackward. These prototypes look okay to me, and again I didn't deliberately invoke them in the first place. Does anybody have any idea how I can get past this roadblock? p.s. this is what the first prototype looks like; no unbalanced parens here (spacing edited for readability): int BNNSApplyMultiheadAttention(BNNSFilter F, size_t batch_size, void const* query, size_t query_stride, void const* key, size_t key_stride, BNNSNDArrayDescriptor const* _Nullable key_mask, size_t key_mask_stride, void const* value, size_t value_stride, void *output, size_t output_stride, BNNSNDArrayDescriptor const* _Nullable add_to_attention, size_t * _Nullable backprop_cache_size, void * _Nullable backprop_cache, size_t * _Nullable workspace_size, void * _Nullable workspace)
3
0
62
May ’25
Xcode build system has crashed after adding opencv to macApp
Hi, I am currently working on a MacOS App, where I need the undistortion function of opencv. But after I tried to add opencv to my project, I get following error: unexpected service error: The Xcode build system has crashed. Build again to continue. Cleaning the build folder also doesn't help. Does anyone have an idea what could be the issue? Ryan
0
0
32
May ’25
Xcode does not see code changes in local Swift packages (autocomplete wrong, errors shown, but still compiles)
Hey, I've been having a lot of problems with Xcode 16 not seeing changes made to code in local Swift packages (the packages are inside the root directory of the project). Whenever I make any change like renaming a variable or type, or adding new methods or whatever, autocomplete doesn't see those changes and when I type in that new type/variable manually it gives me an error. However, building the project still works fine, even with the errors never going away. The only way for it to notice the code changes is to clean the project and build it again which takes a long time. At first, I thought this was connected to the new "Explicitly built modules" feature in Xcode 16, but I turned it off and it still happens. Any ideas what I can try? I'm on the latest Xcode version, but this problem has been happening since Xcode 16 originally came out. Thanks! Dennis
0
0
80
May ’25
Apple SDKs should provide libunwind_ext.h on macOS
(Copy pasted from FB17261080 that I submitted) Hi: Apple's SDK (libSystem.B.tbd) provides definition for multiple symbols(__unw_add_dynamic_fde / __unw_add_find_dynamic_unwind_sections ), but doesn't provide corresponding headers, available in LLVM upstream as libunwind_ext.h We need such headers to write Exception-Enabled JIT Framework for macOS
1
0
125
May ’25
Compiler stuck::considering giving up on SwiftUI
Apologies if this comes off as a bit of a rant, and TLDR: Compiler hangs or gives an unhelpful error with any level of complexity in SwiftUI - which makes me want to back to IB Porting a project over to iPhone. Made great progress the first week. However, lately I have been encountering compiler bugs where either the build never finishes, or the build take a really long time and ends with just the error : The compiler is unable to type-check this expression in reasonable time Sometimes I can get it to go away by playing divide and conquer and finding some small error, but other times with my nested scrollview it just seems unhappy with any level of complexity (and I don't think my views are all that complex compared to lots of other apps out there) I've read several posts on these forums for things to try and do to fix it but the bottom line is its impacting my ability to produce a working solution in a reasonable amount of time. So considering going back to Interface Builder though it means starting over with some of the code. If there was another independent way to syntax check my swiftUI code other than line by line myself I'd welcome something like that. The compiler going away and never coming back is very discouraging -- what if I have to make some kind of emergency fix in the future with limited time? Open for any suggestions. Xcode : 16.2
3
0
63
May ’25
Compiler - method linking issue.
Issue: During app execution, the intended method is not being called; instead, the method preceding (written above the intended method) is being executed. For Example: //In my case the ViewController class is at 3rd level of inheritance. class ViewController: UIViewController { func methodA() { print("methodA") } func methodB() { print("methodB") } } let vc = ViewController() vc.methodB() Output: //"methodA" Expected: //"methodB" Observations: Recent code changes have revealed that enabling the below Swift-6 flag leads to this linking issue. When this flag is commented out, the problem disappears. .enableUpcomingFeature("InternalImportsByDefault") Additionally, moving the intended method into an extension of the same class resolves the issue when the flag is enabled. Conclusion: To resolve the issue: Comment out the Swift-6 flag. Alternatively, move the method into an extension of the same class, which addresses the issue for this specific case. I had similar issue in other class where it crashes with message "method not found", but actually the method is there. When moving the method into an extension of same class resolve this issue. Any help is much appreciated. Thanking you..
2
0
56
May ’25
BUG IN CLIENT OF LIBMALLOC: memory corruption of free block
We've noticed a pretty common crash that's occurring in our app that appears to only be affecting iOS 18 users. The code in question is below: func getThing() async throws -&gt; ThingData { guard shouldRefresh, let data = self.thingData else { let remoteThingData = try await store.getThingData() self.thingData = remoteThingData return remoteThingData // Crash happens here } return data } The crash happens on a background thread and the actual crash is: Crashed: com.apple.root.user-initiated-qos.cooperative EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x00000004a67149c0 We haven't been able to reproduce the error ourselves but in the past 90 days all of the crashes (several thousand) have been only on iOS 18. We also found this thread that appears similar from 2 years ago but unsure if it's related because in our case the guard can only be calculated at runtime so there shouldn't be any optimizations happening.
1
1
531
Apr ’25
Code no longer builds "unsupported option for target"
A short while ago, I added: set(CMAKE_OSX_DEPLOYMENT_TARGET 13.0 CACHE STRING "Minimum operating system version for deployment") to my top level CMake file. The code would not compile. So I removed the line and deleted the CMake cache and tried to rebuild. And for my pains I got this: c++: error: unsupported option '-mavx' for target 'arm64-apple-darwin24.4.0' c++: error: unsupported option '-mavx2' for target 'arm64-apple-darwin24.4.0' c++: error: unsupported option '-mfma' for target 'arm64-apple-darwin24.4.0' c++: error: unsupported option '-mssse3' for target 'arm64-apple-darwin24.4.0' This code was all compiled just fine up until this change, but now it just won't do so. Help!!! David
1
0
64
Apr ’25
Errors compiling C++ code for x86_64
I have a project (that uses pre-compiled headers) that uses different compiler options for SOME files. For those files I have this is in my CMakelists.txt: if(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang") set_source_files_properties(${AVX_Files} PROPERTIES COMPILE_OPTIONS "-mavx;-mavx2;-mfma;-mssse3;-msse4.2") set_source_files_properties(avx_simd_check.cpp PROPERTIES COMPILE_OPTIONS "-mxsave") endif() When I build for ARM, it all works :) When I try to build for X86_64, I get the following error for avx_simd_check.cpp: error: current translation unit is compiled with the target feature '+xsave' but the AST file was not 1 error generated. and for all the other files in question: error: current translation unit is compiled with the target feature '+avx' but the AST file was not error: current translation unit is compiled with the target feature '+avx2' but the AST file was not error: current translation unit is compiled with the target feature '+fma' but the AST file was not error: current translation unit is compiled with the target feature '+sse4.2' but the AST file was not error: current translation unit is compiled with the target feature '+ssse3' but the AST file was not 5 errors generated. How can I solve this please? David
3
0
45
Apr ’25
SwiftUI: Command SwiftCompile failed with a nonzero exit code
I have a SwiftUI app that I've been working on in XCode 16.1. The project builds and runs in the simulators, on my mac and on my iPhone/iPad without any issues. I'm also able to build my unit test project and run them without any errors. The project has zero warnings in it. When I go to the Edit Schemes options and change the Run scheme to be a Release build with the Debug Executable unchecked I get a compiler error: Command SwiftCompile failed with a nonzero exit code I've attempted this Release Run with the following target devices in XCode: My iPhone 15 Pro Max (iOS 18.2 Beta 3) MacBook Air (M1) (15.2 Beta) iPhone 16 Simulator (iOS 18.1) Any iOS Simulator Device (arm64, x86_64) All 3 of these target have the same issue. Normally I would just debug the error from the logs but when I look at the build output I can't see any information in the log to tell me what happened. It looks like the source files are sent into the SwiftCompiler and the compiler fails without bubbling up the issue. I've provided the full error log export as a Gist HERE due to it's size. Is there anything in the log I'm missing? Is there a way for me to turn on more verbose logging during compilation of a Release Build? I created a brand new Multiplatform App in XCode and I added all of my source files to it. No project configuration settings were changed. I could build it successfully with the debug configuration. I then changed it to the Release configuration and experienced the same error. I can create another fresh project and make the same release configuration with none of my source files in it and get a successful build. I t seems there is something wrong with my source files and the release configuration but the compiler doesn't indicate what. I'm lost at this point as I can't figure out how to get a release build and can't seem to find any indication as to why.
11
0
1.4k
Apr ’25
Unable to build c++ ios 18.4 headers with xcode 16.3
I have c++ enabled in my project and they build fine in Xcode 16.2. But now iOS SDK c++ files do not compile since “std::char_traits” support has been dropped from compiler during 16.3 update. This is the error I get: /Developer/SDKs/iPhoneOS18.4.sdk/usr/include/c++/v1/ios:543:64 Implicit instantiation of undefined template 'std::char_traits' At least these are broken, maybe more: ios.h basic_ostream.h string.h string_view.h This is rather annoying that Apple's own header files do not compile. Can't fix it by myself. Also other workarounds than downgrading to 16.2 are welcome. Feedback assistant: FB17183862
1
1
287
Apr ’25
Previews stopped working in Xcode 16.3 with baffling error message
Upgrading to Xcode 16.3, all previews across my AppKit project stopped working. The error message I'm getting is especially baffling. It says the project could not be built with incremental compilation because SWIFT_COMPILATION_MODE is set to "incremental": I tried clearing DerivedData with no effect. When I click the diagnostics button the information given is not very revealing, at least not to me. If I open the project in Xcode 16.2 everything works perfectly again. I switched over to Previews for all new code but this error situation is quite demotivating. Does anyone have any suggestions?
1
2
162
Apr ’25
Significant Performance Regression in Apple Clang 16 for Assembly File Processing
I've observed a significant performance regression in Apple Clang 16 (Xcode 16.0/16.2) compared to Clang 15 (Xcode 15.2) when processing flutter aot compilation. Further research shows that clang -cc1as process became extremely slow. The compilation time has increased by approximately 4x. Environment Machine: Apple M2 (8C8T) Memory: 16GB macOS Version: 14.7.2 Target: Flutter AOT compilation (snapshot_assembly.o) Performance Comparison Xcode Version iOS SDK Duration 15.2 17.2 1:08.90 15.2 18.2 1:03.98 16.2 17.2 4:11.07 16.2 18.2 4:08.43 16.0 18.2 4:29.32 Reproduction Steps The issue can be reproduced with the following command which is generated by flutter aot_assembly_release process: time ${xcode_app_path}/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc \ -arch arm64 \ -miphoneos-version-min=12.0 \ -v \ -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS18.2.sdk \ -c ${project_path}/.dart_tool/flutter_build/f9ebf46f040933de7c8d103c84d38156/arm64/snapshot_assembly.S \ -o ${project_path}/.dart_tool/flutter_build/f9ebf46f040933de7c8d103c84d38156/arm64/snapshot_assembly.o Additional Information This issue specifically affects large assembly files generated by Flutter's AOT compilation The performance regression appears to be consistent across different iOS SDK versions The same assembly file compiles significantly faster with Xcode 15.2 Same performance regression observed on M4 Mac mini, suggesting this is not hardware-specific Size of object: size -m ${project_path}/.dart_tool/flutter_build/f9ebf46f040933de7c8d103c84d38156/arm64/snapshot_assembly.o Segment : 64577616 Section (__TEXT, __text): 26603344 Section (__DATA, __bss): 48 (zerofill) Section (__TEXT, __const): 21292928 Section (__DWARF, __debug_abbrev): 61 Section (__DWARF, __debug_info): 8934534 Section (__DWARF, __debug_line): 4464443 Section (__LD, __compact_unwind): 3282208 total 64577566 total 64577616 Questions Is this a known issue with Apple Clang 16? Are there any workarounds or compiler flags we can use to improve the performance? Is this behavior expected or should it be considered a regression? Any insights or suggestions would be greatly appreciated.
4
0
159
Apr ’25
Command line compilation problem, standard includes not found
This example fails to compile on Sequoia 15.4 with Xcode 16.3 and the command line tools installed; jacquesmenu@macstudio:C++Tests &gt; cat pcount_test.cpp // clang++ -std=c++17 -o IntWrapperTest IntWrapperTest.cpp #include // std::string #include // std::cout #include // std::ostringstream int main1 (int argc, char* argv[]) { std::string theString = "Prière d'éviter"; std::cout &lt;&lt; theString &lt;&lt; ", size(): " &lt;&lt; theString.size () &lt;&lt; std::endl; std::stringstream oss; oss &lt;&lt; theString &lt;&lt; std::endl; std::cout &lt;&lt; oss.str () &lt;&lt; ", pcount(): " &lt;&lt; oss.pcount () &lt;&lt; std::endl; } //_______________________________________________________________________________ // position in output stream #include // std::ofstream int main () { std::ofstream outfile; outfile.open ("test.txt"); outfile.write ("This is an apple",16); long pos = outfile.tellp(); outfile.seekp (pos-7); outfile.write (" sam",4); outfile.close(); return 0; } jacquesmenu@macstudio:C++Tests &gt; clang++ pcount_test.cpp pcount_test.cpp:3:10: fatal error: 'string' file not found 3 | #include // std::string | ^~~~~~~~ 1 error generated. The same occurs with iostrem if it is the first include mentioned. Compiling in Xcode itself does not this problem, though. This include is to be found here: jacquesmenu@macstudio:C++Tests &gt; xcode-select -p /Applications/Xcode.app/Contents/Developer jacquesmenu@macstudio:C++Tests &gt; ls -sal /Applications/Xcode.app/Contents/Developer/**/string | grep MacOSX 72 -rw-r--r-- 10 root wheel 203802 Mar 8 06:17 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/string
3
0
57
Apr ’25
Xcode 16 Build & Archive Error - SPM
Since upgrading from Xcode 15 to 16, we have been experiencing a build error during compilation. Building on Xcode 15 still works with no issues. The error happens only on the first build after a clean. Subsequent builds succeed. This is an issue because our CI process archives the project from a clean slate, and this causes it to fail every time. I will attempt to describe the issue and include information I believe is relevant in this document. The error occurs on this import line within an Objective-C file during the Scan Dependencies step of compiling. This line imports our custom Objective-C to Swift bridging header file - "Swift2Objc.h". Our custom Objective-C to Swift bridging header file is simply wrapping the project’s auto-generated Objective-C to Swift bridging header file - "KWISwift.h". The error is specific to the import of the OfflineServices Swift Package. Specifically, the OfflineServices-Swift.h file - the Swift Package’s auto-generated Objective-C to Swift bridging file. Module JRE not found - the exact error (Also included as text on the bottom of the post) JRE is a third-party library provided to us as an xcframework. It is placed directly into our Swift Package as a binary target. The xcframework itself is composed of .a file and a Headers folder which includes header files and a module.modulemap. The module.modulemap file looks like this.
0
0
107
Mar ’25